// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
  return request<{
    data: API.CurrentUser;
  }>('/api/user/current', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 退出登录接口 POST /api/account/logout */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/account/logout', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 登录接口 POST /api/account/login */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.LoginResult>('/api/account/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>('/api/notices', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RuleList>('/api/rule', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    method: 'DELETE',
    ...(options || {}),
  });
}

/** 获取角色列表 GET /api/role */
export async function getRoles(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.ResData<API.RoleItem>>('/api/role', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建角色 POST /api/role */
export async function addRole(body: API.RoleItem, options?: { [key: string]: any }) {
  return request('/api/role', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取全部菜单 GET /api/menu */
export async function getAllMenu(options?: { [key: string]: any }) {
  return request<API.ResData<API.MenuItem>>('/api/menu', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取全部API GET /api/api/all */
export async function getAllApi(options?: { [key: string]: any }) {
  return request<API.Api[]>('/api/api/all', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 更新角色 PUT /api/role */
export async function updateRole(body: API.RoleItem, options?: { [key: string]: any }) {
  return request('/api/role', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除角色 DELETE /api/role */
export async function removeRole(body: API.RoleItem, options?: { [key: string]: any }) {
  return request('/api/role', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 添加菜单 POST /api/menu */
export async function addMenu(body: API.MenuItem, options?: { [key: string]: any }) {
  return request('/api/menu', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 更新菜单 PUT /api/menu */
export async function updateMenu(body: API.MenuItem, options?: { [key: string]: any }) {
  return request('/api/menu', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除菜单 DELETE /api/menu */
export async function removeMenu(body: API.MenuItem, options?: { [key: string]: any }) {
  return request('/api/menu', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取API GET /api/api */
export async function getApis(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.ResData<API.ApiItem>>('/api/api', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 添加API POST /api/api */
export async function addApi(body: API.ApiItem, options?: { [key: string]: any }) {
  return request('/api/api', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 更新API PUT /api/api */
export async function updateApi(body: API.ApiItem, options?: { [key: string]: any }) {
  return request('/api/api', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除API DELETE /api/api */
export async function removeApi(body: API.ApiItem, options?: { [key: string]: any }) {
  return request('/api/api', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 获取后台日志 GET /api/log */
export async function getLogs(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.ResData<API.LogItem>>('/api/log', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}
